package com.gxd.business.controller;

import com.gxd.business.domain.Customer;
import com.gxd.business.domain.qco.CustomerQco;
import com.gxd.business.enums.ReferrerEnum;
import com.gxd.business.service.CustomerService;
import com.gxd.common.core.controller.BaseController;
import com.gxd.common.core.domain.AjaxResult;
import com.gxd.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author gxd
 * @since 2025/6/16
 */
@RestController
@RequestMapping("/publicCustomer")
@Api(tags = "公共客户资源")
public class PublicCustomerController extends BaseController {

    @Autowired
    private CustomerService customerService;

    @ApiOperation("分页列表-公共客户资源列表")
    @PostMapping("/pageList")
    public TableDataInfo pageList(@ApiParam(value = "公共客户资源查询条件") @RequestBody CustomerQco customerQco) {
        // 设置访问来源参数
        customerQco.setReferrer(ReferrerEnum.PUBLICCUSTOMER.getCode());
        List<Customer> customers = customerService.pageList(customerQco);
        return getDataTable(customers);
    }

    @ApiOperation("修改-公共客户资源")
    @PostMapping("/edit")
    public AjaxResult edit(@ApiParam(value = "公共客户资源实体", required = true) @Valid @RequestBody Customer customer) {
        return success(customerService.edit(customer));
    }
}
